<?php

class AuthController extends BaseController {

     /**
    * 页面：登录
    * @return Response
    */
    public function getLogin()
    {
        return View::make('auth.login');
    }
    public function postLogin(){
        //用户凭证
        $user = array('username' => Input::get('username'),'password' => Input::get('password') );
        //是否记住登录状态
        $remember = Input::get('remember-me', 0);
        if(Auth::attempt($user, $remember)){
            // 登录成功，跳回之前被拦截的页面
            return Redirect::intended();
        }else{
            // 登录失败，跳回
            return Redirect::back()
                ->withInput()
                ->withErrors(array('attempt'=>'“用户名”或“密码”错误，请重新登录。'));
        }

    }
    /**
     * 注销登录
     *
     * @return Response
     */
    public function getLogout()
    {
        Auth::logout();
        return Redirect::to('/auth/login')
            ->withErrors(array('attempt'=>'你已经成功注销当前登录。'));
    }
}
